package com.itheima.tlias.controller;

import com.itheima.tlias.annotation.Log;
import com.itheima.tlias.common.result.Result;
import com.itheima.tlias.pojo.po.InsertClazzParam;
import com.itheima.tlias.pojo.po.SelectClazzPageParam;
import com.itheima.tlias.pojo.po.UpdateClazzParam;
import com.itheima.tlias.service.ClazzService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/clazzs")
public class ClazzController {
    @Resource
    private ClazzService clazzService;
    @GetMapping
    public Result selectClazzByPage(SelectClazzPageParam param) {
        log.info("班级管理分页查询参数,{}", param);
        return clazzService.selectClazzByPage(param);
    }
    @Log
    @PostMapping
    public Result insertClazz(@RequestBody InsertClazzParam param){
        log.info("添加班级参数,{}",param);
        return clazzService.insertClazz(param);
    }
    @GetMapping("/{id}")
    public Result selectClazzById(@PathVariable("id") Integer id){
        log.info("查询班级参数,{}",id);
        return clazzService.selectClazzById(id);
    }
    @Log
    @PutMapping
    public Result updateClazz(@RequestBody UpdateClazzParam param){
        log.info("修改班级参数,{}",param);
        return clazzService.updateClazz(param);
    }
    @Log
    @DeleteMapping("/{id}")
    public Result delectClazzById(@PathVariable("id") Integer id){
        return clazzService.delectClazzById(id);
    }
    @GetMapping("/list")
    public Result selectClazzAll(){
        return clazzService.selectClazzAll();
    }
}
